package com.zerotwo.exam.user.mapper;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zerotwo.exam.user.model.JoinClass;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zerotwo.exam.user.model.UserAuthInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.Collection;


/**
 * @author 02
 * @version 1.0
 * @Date 2024/7/5
 * @Description Mapper 接口
 */
@Mapper
public interface JoinClassMapper extends BaseMapper<JoinClass> {

    IPage<UserAuthInfo>  getJoinClassUser(IPage<UserAuthInfo> page, Wrapper<JoinClass> ew);
    JoinClass getJoinByCourseId(Integer courseId,Integer userId);

    Integer getStudentNumberByIds(Collection<Integer> ids,Integer userId);

    //查询要删除/修改的joinid
    @Select("SELECT j.id FROM ec_join_class j INNER JOIN ec_classes c ON j.class_id = c.id INNER JOIN es_user u ON j.student_id = u.id where u.id =  #{uId} and c.id = #{cId} LIMIT 1;")
    Integer getJoinIds(Integer uId,Integer cId);}
